package com.itita.ww2.model.basemap;

import com.smartfoxserver.v2.entities.data.ISFSObject;

public class MapUnit {
	private String mapCode; // unit code
	private String bdCode; // 建筑code
	private int level; // 等级
	private ISFSObject obj; // 整个obj
	// 
	private MapUnitType type; // 类别

	public static enum MapUnitType {
		BA, // 固定建筑
		BD // 防御建筑
	}

	public MapUnit(String mapCode, ISFSObject data) {
		this.mapCode = mapCode;
		this.obj = data;
		if (data.size() == 0) {
			this.type = MapUnitType.BA;
		} else {
			this.type = MapUnitType.BD;
			this.bdCode = obj.getUtfString("ID");
			this.level = obj.getInt("Lv");
		}
	}

	public synchronized void upgrade() {
		// TODO 升级
	}

	public synchronized void upgradeComplete() {
		// TODO 升级完成
	}

	/**
	 * 获取所代表的建筑代码
	 */
	public String getBDCode() {
		return this.bdCode;
	}

	public int getLevel() {
		return this.level;
	}

	public String getMapCode() {
		return this.mapCode;
	}

	public MapUnitType getType() {
		return this.type;
	}

	public ISFSObject toSFSObject() {
		return this.obj;
	}
}
